package com.wang.controller;

import com.wang.reponse.EvaluationVo;
import com.wang.result.BaseResponse;
import com.wang.result.ResultUtils;
import com.wang.user.model.Evaluation;
import com.wang.user.service.EvaluationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/evaluation")
@Api(tags = "评价商铺管理")
public class EvaluationController {

    @Resource
    private EvaluationService evaluationService;

    @PostMapping("/submit")
    @ApiOperation(value = "评价商铺")
    public BaseResponse<Boolean> collection(@RequestBody Evaluation evaluation) {
        return ResultUtils.success(evaluationService.submit(evaluation));
    }

    @PostMapping("/delete/{id}")
    @ApiOperation(value = "删除评价")
    public BaseResponse<Boolean> delete(@PathVariable Long id) {
        return ResultUtils.success(evaluationService.deleteById(id));
    }

    @GetMapping("/get/{id}")
    @ApiOperation(value = "获取商铺下的所有评论")
    public BaseResponse<List<EvaluationVo>> getByShopId(@PathVariable Long id) {
        return ResultUtils.success(evaluationService.getByShopId(id));
    }

}
